<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="static/jquery-easyui-1.5.5.3/jquery.min.js"></script>
	<link rel="stylesheet" href="webjars/bootstrap/3.3.7-1/css/bootstrap.css">
	<link rel="stylesheet" href="static/jquery-easyui-1.5.5.3/themes/material-teal/easyui.css" />
	<link rel="stylesheet" href="static/jquery-easyui-1.5.5.3/themes/icon.css" />
	<link rel="stylesheet" href="static/css/customForm.css">
	<script type="text/javascript" src="static/jquery-easyui-1.5.5.3/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="static/jquery-easyui-1.5.5.3/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="webjars/bootstrap/3.3.7-1/js/bootstrap.js"></script>
	<script type="text/javascript">
	$(function(){
		$("#t_log").datagrid({
			idField:'id',
			title: '操作日志',
			width: '100%',
			fitColumns: true,
			striped: true,
			loadMsg: '数据正在加载...',
			rownumbers: true,
			url: 'listLog',
			columns:[
				[
					{
						field: 'id',
						title: '唯一标识',
						width: 50,
						hidden:true,
						align: 'center'
					}, {
						field:'name',
						title:'真实姓名',
						width: 100,
						align: 'center'
					},{
						field:'username',
						title:'读者登陆名',
						width: 100,
						align: 'center'
					},{
						field:'date',
						title:'操作时间',
						width: 100,
						align: 'center'
					},{
						field: 'operation',
						title: '操作',
						width: 100,
						align: 'center'
					}
				]
			],
				pagination: true,
				pageSize:10,
				pageList: [ 10, 20, 25, 50]
		});
		$('#searchbtn').click(function(){
			$('#t_log').datagrid('load',serializeForm($('#mysearch').form()));
		});
		$('#clearbtn').click(function(){
			$('#mysearch').form('clear');
			$("#t_log").datagrid('load', {});
		});
	});
	
	//js方法，序列化表单，因为查询不传值去后台，无法辨认传的参数是否有
	function serializeForm(form){
		var obj = {};
		$('#id').val("1");
		$.each(form.serializeArray(), function(index){
			if(obj[this['name']]){
				obj[this['name']] = obj[this['name']] + ',' + this['value'];
			}else{
				obj[this['name']] = this['value'];
			}
		});
		return obj;
	}
	function only(value){
		$.post('only',{username:value},function(data){
			$("#username_error").html(data);			
		});
	}
	</script>
</head>
<body>
	<div style="padding: 20px;">
		<form id="mysearch">
			<input type="hidden" name = "id" id="id">
			<div class="col-md-3">			
				<div class="input-group">
					<span class="input-group-addon">真实姓名</span>
					<input type="text" class="form-control" name="name" placeholder="姓名">
				</div>
			</div>
			<div class="col-md-3">			
				<div class="input-group">
					<span class="input-group-addon">读者登陆名</span>
					<input type="text" class="form-control" name="username" placeholder="读者登陆名">
				</div>
			</div>
			<div class="col-md-3">			
				<div class="input-group">
					<span class="input-group-addon">操作事情</span>
					<input type="text" class="form-control" name="operation" placeholder="操作事情">
				</div>
			</div>
			<div class="btn-group">
				<button id="searchbtn" class="btn btn-success"><span class="glyphicon glyphicon-search"></span> 查询</button>
				<button id="clearbtn" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> 清空</button>
			</div>
		</form>
	</div>
<table id="t_log"></table>

</body>
</html>